package com.blue.base.common.utils.bean;

/**
 * 参数校验工具类
 *
 * @author liulei
 * @version 1.0
 */
public class ParamCheckUtil {

    private ParamCheckUtil() throws IllegalAccessException {
        throw new IllegalAccessException("com.blue.base.web.util class can not be instanced");
    }

    private static final String PHONE_REX =
            "^[1](([3|5|8|9][\\d])|([4][4,5,6,7,8,9])|([6][2,5,6,7])|([7][^9])|([9][1,8,9]))[\\d]{8}$";

    /**
     * 多个字符串判断不为空
     *
     * @param str 字符串
     * @return 结果
     */
    public static boolean strIsNotEmpty(String... str) {
        if (str == null) {
            return false;
        }
        for (int i = 0; i < str.length; i++) {
            if (str[i] == null || "".equals((str[i]).trim())) {
                return false;
            }
        }
        return true;
    }

    /**
     * 电话号码校验
     *
     * @param phone 电话
     * @return 结果
     */
    public static boolean isPhone(String phone) {
        if ("".equals(phone) || null == phone) {
            return false;
        }
        if (phone.matches(PHONE_REX)) {
            return true;
        }
        return false;
    }
}
